home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / os2 / srefv112.zip / SREFPRC1.ZIP / MAKEB.SRF < prev    next >
Text File  |  1996-04-28  |  1KB  |  37 lines

  1. /* ----------------------------------------------------------------------- */
  2. /* MAKE BLOCK: Replace all occurences of NEEDLE in HAYSTACK
  3. .        with delim1 needle delim2.
  4. .        If delim1 and delim2 not give, then { AND } are used.
  5. .   Example: make_block(boys,' there are wild boys out there','<b>',' </b>')
  6. .      returns 'there are wild <b>boys </b> out  there'
  7. .      (note that spaces are all retained)
  8. */
  9. /* ----------------------------------------------------------------------- */
  10.  
  11. sref_make_block:
  12.  
  13. parse arg needle, haystack, delim1 , delim2, check_case
  14. if delim1="" then delim1='{'
  15. if delim2="" then delim1='}'
  16.  
  17. build=""
  18. do forever
  19.   if check_case<>1 then
  20.      mm=pos(translate(needle),translate(haystack))
  21.   else
  22.      mm=pos(needle,haystack)
  23.  
  24.   if mm=0 then do
  25.     build=build||haystack
  26.     return build
  27.   end
  28.  
  29.   t1=substr(haystack,1,mm-1)
  30.   t2=substr(haystack,mm,length(needle))
  31.   haystack=substr(haystack,mm+length(needle))
  32.   build=build||t1||delim1||t2||delim2
  33.  
  34. end
  35.  
  36.  
  37.